package com.org.flow.element.order;

import com.org.flow.core.exception.FlowBusException;
import com.org.flow.system.model.bo.order.GovernmentBO;
import com.org.flow.system.service.LinkService;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@LiteflowComponent(id = "lite_other_star", name = "预受理_其他渠道_启动")
@Slf4j
@RequiredArgsConstructor
public class CmpFromOther extends NodeComponent {

    private  final LinkService service;
    @Override
    public void process() {
        boolean c = service.process("lite_other_star", "预受理_其他渠道_启动");
        if (!c) {
            throw new FlowBusException("50010003", "Cannot process lite_other_star");
        }
    }

    @Override
    public void beforeProcess() {
        super.beforeProcess();
        GovernmentBO bo = this.getSlot().getRequestData();
        if (bo.getAddress() != null && !bo.getAddress().equals("")) {
            log.info("校验通过");
        } else {
            log.info("校验失败!");
            throw new FlowBusException("50010002", "Invalid address failed ");
        }
    }
}
